package com.example.demo.controller;

import com.example.demo.annotation.Roles;
import com.example.demo.annotation.SystemAdmin;
import com.example.demo.dto.PageDTO;
import com.example.demo.dto.ServiceAddDTO;
import com.example.demo.pojo.Result;
import com.example.demo.pojo.Service;
import com.example.demo.service.ServiceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/service")
@Slf4j
@Tag(name = "服务接口")
@RequiredArgsConstructor
public class ServiceController {
    private final ServiceService serviceService;
    @PostMapping
    @Operation(summary = "添加服务")
    @Roles(values = "sa")
    public Result addService(@RequestBody ServiceAddDTO serviceAddDTO) {
        serviceService.addService(serviceAddDTO);
        return Result.success();
    }
    @GetMapping()
    @Operation(summary = "获取服务列表")
    @Roles(values = {"sa", "da", "ru"})
    public Result<List<Service>> getServiceList(PageDTO pageDTO) {
        return Result.success(serviceService.getServiceList(pageDTO));
    }

}
